package com.yungu.swift.admin.route.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.assets.passenger.model.dto.PassengerDto;
import com.yungu.swift.assets.passenger.service.PassengerService;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.PageVo;
import com.yungu.swift.order.model.param.OrderReturnVisitParam;
import com.yungu.swift.order.model.vo.AdminOrderReturnVisitVo;
import com.yungu.swift.order.service.OrderReturnVisitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/admin/v1/orderReturnVisit")
@Api(value = "【订单管理】", tags = "首单回访相关")
public class OrderReturnVisitAdmin {

    @Reference
    private OrderReturnVisitService orderReturnVisitService;
    @Reference
    private PassengerService passengerService;

    @PostMapping("/queryPage")
    @ApiOperation(value = "首单回访信息分页", httpMethod = "POST")
    public ResponseData<PageVo<AdminOrderReturnVisitVo>> queryPage(@RequestBody OrderReturnVisitParam orderReturnVisitParam) {
        return orderReturnVisitService.queryFirstOrderInfo(orderReturnVisitParam);
    }

    @PostMapping("/handle")
    @ApiOperation(value = "回访操作", httpMethod = "POST")
    public ResponseData<Boolean> handleReturnVisit(@RequestBody OrderReturnVisitParam orderReturnVisitParam) {
        PassengerDto passengerDto = new PassengerDto();
        passengerDto.setUuid(orderReturnVisitParam.getPassengerUuid());
        passengerDto.setReturnVisitStatus(1);
        return passengerService.edit(passengerDto);
    }
}
